import os

from datetime import timedelta

basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
    SECRET_KEY =os.environ.get('SECRET_KEY') or 'sd13ad4bf5a6e@sdab/sdb654d!sdfgnsfgm56564'
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    @staticmethod
    def init_app(app):
        pass

#开发环境配置
class DevelopmentConfig(Config):
    DEBUG = True
    PERMANENT_SESSION_LIFETIME = timedelta(days=7)
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or 'sqlite:///' + \
                              os.path.join(basedir,'data.sqlite3') + '?check_same_thread=False'


#测试环境配置
class TestinsConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or 'sqlite:///' + \
                              os.path.join(basedir, 'data.sqlite3') + '?check_same_thread=False'

#生产环境配置
class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or 'sqlite:///' + \
                              os.path.join(basedir,'data.sqlite3') + '?check_same_thread=False'

config = {
    'development':DevelopmentConfig,
    'testing':TestinsConfig,
    'production':ProductionConfig,
    'default':DevelopmentConfig
}